|
|
|
|
|
|
|
The definition statements are located in the General Descriptions area of the form's code. You need to add the following definitions to the form: |
|
|
|
|
|
|
|
|
Option Explicit
Dim lngFileSize As Long
Dim intLoopCtr As Integer
Dim intBufferCount As Integer
Dim strInByte As String * 256
Dim strFrom_filename As String
Dim strTo_filename As String
Dim strAvi_Filename As String
Const ActionCopy = 1
Const ActionMove = 0 |
|
|
|
|
|
|
|
|
Notice that two constants are defined to make the code easier to understand. ActionMove and ActionCopy, instead of the sometimes cryptic 1 or 0, serve to explain what the code segments are doing. |
|
|
|
|
|
|
|
|
As you can see from this example, the Open and Save As dialog boxes can perform some very needed services within your application. The trick is knowing how to use them. |
|
|
|
|
|
|
|
|
Now, the application you just created enables you to copy or move any file to another location on your computer. One of the things you need to do before moving or copying a file is to check if the target drive has enough room for the file. Prior to VB6, you needed to use Windows API calls to get the available space on the drive. Included with VB6 is the File System Objects. These include objects that enable you to get information about the following: |
|
|
|
|
|
|
|
|
Drive or Drives attached to your computerEnables you to get any information needed about the specified drive or drives. |
|
|
|
|
|
|
|
|
Folder or FoldersEnables you to create, delete, or move folders, plus access their names, paths, and so on. |
|
|
|
|
|
|
|
|
FilesEnables you to create, delete, or move files, plus access their names, paths, and so on. |
|
|
|
|
|
|
|
|
FileSystemObjectEnables you to create, delete, and get information about any of the previous objects. |
|
|
|
|
|
|
|
|
To use these objects, you need to include the SCRRUN.DLL file (which can be found in the WINDOWS\SYSTEM directory) on the Project, References dialog. For the purpose of this example, use the File System Objects to get the following information: |
|
|
|
|
|
|
|
|
Available space on the target drive |
|
|
|
|
|
|
|
|
Total space on the target drive |
|
|
|
|
|
|
|
|
Total size of the file being copied |
|
|
|
|
|